
<?php
header("content-type:text/html;charset=utf-8");

class db2{
	private $localhost = "localhost";
	private $name = "root";
	private $code = "root";
	private $database = "pro";
	private $con;
	private $rs;
	private $myrow;
	private $numrows;
	private $pages;
	private $page;
	private $first=1;
	private $prev;
    private $next;
    private $last;



function connect(){
	$this->con = mysql_connect($this->localhost,$this->name,$this->code);
	mysql_select_db($this->database,$this->con);
	mysql_query("set names utf8");
}

function __construct(){
    $this->connect();
}

function __destruct(){
    mysql_close($this->con);
}

function p($pagesize){
$this->rs = mysql_query("select count(*) from product",$this->con);
$this->myrow = mysql_fetch_array($this->rs);
$this->numrows = $this->myrow[0];

$this->pages = intval($this->numrows/$pagesize);
if($this->numrows%$pagesize) 
$this->pages++;
$this->page = isset($_GET['page'])?$_GET['page']:1;


echo "<div align='center'>共有"."{$this->pages}"."页(".$this->page."/".$this->pages.")";
      $this->first;
      $this->prev=$this->page-1;
      $this->next=$this->page+1;
      $this->last=$this->pages;

      if ($this->page > 1){
      echo '<a href="shi.php?page='.$this->first.'">首页</a>';
        echo '<a href="shi.php?page='.$this->prev.'">上一页</a>';
      }
      if ($this->page < $this->pages){
              echo '<a href="shi.php?page='.$this->next.'">下一页</a>';
              echo '<a href="shi.php?page='.$this->last.'">尾页</a>';
      }


}
}

$dbc = new db2();
$dbc->p('1');




?>















































